#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "tcpdatareceiver.h"
#include <QMainWindow>
#include <QTableWidget>
#include <QHeaderView>
#include <QWidget>
#include <QLabel>
#include <QPushButton>
#include <QTextEdit>
#include <QLineEdit>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include<QTcpServer>
#include<QTcpSocket>
namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
   explicit MainWindow(QTcpSocket *socket,QMainWindow *parent = nullptr);
    ~MainWindow();
   void SetUi();
   void setupConnections();
   void soket_statue();
   void display();
private slots:
    void onSearchClicked();
    void onButton1Clicked();
    void onButton2Clicked();
    void onButton3Clicked();
    void onButton4Clicked();
private:
    void displayData(const QString &filterType = "");
    void addTableRow(const QString &trackingNumber,
                    const QString &route,
                    const QString &type,
                    const QString &warehouse);
    void parseTypeAndWarehouse(const QString &typeInfo, const QString &warehouseInfo,
                                         QString &type, QString &warehouse);
      void processPackageData(const QString &rawData);
   QString processRoute(const QString &rawRoute);
    QTableWidget *tableWidget;
    QList<QStringList> packageData; // 存储数据
    Ui::MainWindow *ui;
    QTcpSocket *my_socket;
    // 顶部组件
    QLabel *titleLabel;

    // 左边按钮
    QPushButton *button1;
    QPushButton *button2;
    QPushButton *button3;
    QPushButton *button4;
    // 右边组件
    QLineEdit *searchLineEdit;
    QPushButton *searchButton;
    QTextEdit *textEdit;

    // 布局
    QHBoxLayout *mainLayout;
    QVBoxLayout *leftLayout;
    QVBoxLayout *rightLayout;
    QHBoxLayout *searchLayout;

    QWidget *centralWidget;


};

#endif // MAINWINDOW_H
